<!-- 筛选项：前端固定日期区间、上传按钮
列表行操作：前端固定编辑 删除 -->
<template>
  <!-- 搜索框 -->
  <MyFilter :partParams="basicParams" @get-data="getData" @get-table-data="getTableData" @open-modal="openModal" @open-upload-modal="openUploadModal" />
  <!-- 列表 -->
  <MyTable ref="table" :partParams="tableParams" :tableInfo="tableInfo" />
  <!-- 新增弹框 -->
  <AddModal ref="modalRef" :partParams="basicParams" @refresh="refresh" />
  <!-- 上传弹框 -->
  <UploadModal ref="uploadModalRef" :partParams="basicParams" @refresh="refresh" />
</template>

<script lang="ts" setup>
import MyFilter from './components/MyFilter.vue'
import MyTable from './components/MyTable.vue'
import AddModal from '../common/AddModal.vue'
import UploadModal from '../common/UploadModal.vue'
import { defineProps, ref } from 'vue'
import { useMessage } from '@/hooks/useMessage'

//定义接收的props
const props = defineProps({
  // 定义一个对象类型的 prop
  data: {
    type: Object,
    default: () => ({ groupName: '', jobType: '' })
  }
})

const basicParams = {
  groupName: props.data.groupName,
  jobType: props.data.jobType,
  operType: 'GetList'
}

const tableParams = ref()

const table = ref()
/** 查询列表 */
const getData = async (query: any) => {
  tableParams.value = JSON.parse(JSON.stringify(query))
}

const tableInfo = ref([])
// 获取表格信息
const getTableData = (data: any) => {
  tableInfo.value = data
}

const message = useMessage()
//新增
const modalRef = ref()
const openModal = async () => {
  modalRef.value.open()
}

//上传
const uploadModalRef = ref()
const openUploadModal = async () => {
  uploadModalRef.value.open()
}

const refresh = () => {
  tableParams.value = {
    ...basicParams,
    ...tableParams.value
  }
}
</script>
